<%--
  Created by IntelliJ IDEA.
  User: yinshankun
  Date: 2020/11/20
  Time: 19:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%String path = request.getContextPath();%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script src="<%=path%>/ysk/js/jquery-3.5.1.min.js"></script>
<html>
<head>
    <title>Title</title>
</head>
<body>
<div>

    <form action="/fileUpload.do" enctype="multipart/form-data" method="post" id="fileUploadForm">

        <input type="file" name="file"/><br/>

        <input type="file" name="file"/><br/>

        <input type="file" name="file"/><br/>

        <input type="button" value="上传" id="upLoadButton"/>

    </form>

</div>


</body>
</html>
<script type="text/javascript">

    var uploading = false; //上传状态

    //文件上传

    $("#upLoadButton").click(function(){

        if(uploading){

            alert("文件正在上传中，请稍候...");

            return false;

        }

        $.ajax({

            url: "/fileUpload.do",

            type: 'POST',

            cache: false, //上传不使用缓存

            data: new FormData($('#fileUploadForm')[0]), //form表单内容使用formData组装

            processData: false,

            contentType: false,

            dataType:"json", //返回值类型

            beforeSend : function(){

                uploading = true;

            },

            success : function(data) {

                alert(data.remindMsg);

                uploading = false;

            }

        });

    });

</script>